<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式中的多行匹配修正符m</title>
</head>
<body>
    <script>
        let hd = `
        #1 js,200元 #
        #2 php,300元 #
        #3 houdunren.com # 后盾人
        #4 node.js,180元 #
        `;

        // m表示多行匹配修饰符
        let lessons = hd.match(/^\s*#\d+\s.+\s#$/gm).map(item => {
            item = item.replace(/^\s*#\d+\s/,'').replace(/\s+#$/,'');
            [name,price] = item.split(',');
            return {name,price};
        });
        console.log(lessons);
    </script>
</body>
</html>